package com.abm;

//import java.io.File;
import java.util.ArrayList;
import java.util.List;

//import com.abm.ProductActivity.CustomAdapter_product_iconrow_custom;
import com.abm.data.DatabaseManager;
//import com.abm.dbclases.Product;
import com.abm.dbclases.ProductLog;
import com.abm.entity.ListaActividad;

//import amalgame.ventas.R;
import android.os.Bundle;
//import android.os.Environment;
//import android.app.Activity;
import android.content.Context;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.graphics.Color;
//import android.view.LayoutInflater;
//import android.view.Menu;
//import android.view.View;
//import android.view.ViewGroup;
//import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
//import android.widget.BaseAdapter;
//import android.widget.Filter;
//import android.widget.Filterable;
//import android.widget.ImageButton;
//import android.widget.ImageView;
import android.widget.ListView;
//import android.widget.TextView;
//import android.widget.Filter.FilterResults;

public class ProductLogActivity extends ListaActividad {

	ListView listView;
	List<ProductLog> productLogList;
	List<String> productLogListStr;
	ArrayAdapter<?> aa;

	private DatabaseManager manager;
	private Context mContext;
	public static String PATH_APPDIRs = "sistema_ventas";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		String lista[] = {""};
		
		setContentView(R.layout.activity_product_log);
		
		mContext = getApplicationContext();
		manager = DatabaseManager.getInstance();
		
		aa = new ArrayAdapter<String>(this, R.layout.elemento_lista, lista);

		setListAdapter(aa);
		
		listView = (ListView) getListView();

		showProductLogList();
		
	}

	private void showProductLogList() {
		productLogList = manager.getAllProductLog();
		productLogListStr = new ArrayList<String>();
		
		
		if (productLogList == null || productLogList.size() < 1){	
			productLogListStr.add( getString(R.string.no_item_added)  );
//			unregisterForContextMenu(listView);
		}else{
			for (ProductLog LogItem : productLogList) {
				String name=  "Name: "+manager.getProductByID(LogItem.getId()).getName()+"\n";
				String quantity= "Quantity: "+String.valueOf(LogItem.getQuantity())+"\n";
//				String date= "Date: "+String.valueOf(LogItem.getMovement_date());
				productLogListStr.add(name+quantity); // +date
				
			}
			registerForContextMenu(listView);
		}
		
		ArrayAdapter<String> customAdapter = new ArrayAdapter<String>(mContext, R.layout.elemento_lista, productLogListStr);

		setListAdapter(customAdapter);		
		
		

	}


	
	
}
